from django.db import models
from django.utils import timezone

# Create your models here.

# 数据字典表


class DictType(models.Model):
    """数据字典"""
    dictId = models.IntegerField(primary_key=True)
    dictValue = models.CharField(max_length=50)
    dictCode = models.CharField(max_length=20)
    dictFlag = models.IntegerField()
    dictCreateDate=models.DateTimeField(default=timezone.now)

    class Meta:
        ordering = ('-dictId',)

    def __unicode__(self):
        return self.dictValue

    def __str__(self):
        return self.dictValue + ':' + self.dictCode


class Post(models.Model):
    """文章发表"""
    title = models.CharField(max_length=200)
    slug = models.CharField(max_length=200)
    body = models.TextField()
    pub_date = models.DateTimeField(default=timezone.now)

    class Meta:
        ordering=('-pub_date',)

    def __str__(self):
        return self.title
